﻿using System;

namespace Space2D_Utils
{
	public struct Vector2l
	{
		public Vector2l(long x, long y)
			: this()
		{
			Set(x, y);
		}

		public void Set(Vector2l vec)
		{
			Set(vec.X, vec.Y);
		}

		public void Set(long x, long y)
		{
			X = x;
			Y = y;

			SqrLength = X * X + Y * Y;
			SqrtLength = Math.Sqrt(SqrLength);
		}

		public static bool operator ==(Vector2l a, Vector2l b)
		{
			if (System.Object.ReferenceEquals(a, b))
			{
				return true;
			}

			if (((object)a == null) || ((object)b == null))
			{
				return false;
			}

			return a.X == b.X && a.Y == b.Y;
		}

		public static bool operator !=(Vector2l a, Vector2l b)
		{
			if (System.Object.ReferenceEquals(a, b))
			{
				return true;
			}

			if (((object)a == null) || ((object)b == null))
			{
				return false;
			}

			return a.X != b.X || a.Y != b.Y;
		}

		public override bool Equals(object obj)
		{
			return base.Equals(obj);
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		public override string ToString()
		{
			return "X " + X + ", Y " + Y;
		}

		public static Vector2l operator -(Vector2l a)
		{
			return new Vector2l(-a.X, -a.Y);
		}

		public static Vector2l operator +(Vector2l a, Vector2l b)
		{
			return new Vector2l(a.X + b.X, a.Y + b.Y);
		}

		public static Vector2l operator -(Vector2l a, Vector2l b)
		{
			return new Vector2l(a.X - b.X, a.Y - b.Y);
		}

		public static Vector2l operator *(Vector2l a, long b)
		{
			return new Vector2l(a.X * b, a.Y * b);
		}

		public static Vector2l operator *(long b, Vector2l a)
		{
			return new Vector2l(a.X * b, a.Y * b);
		}

		public static Vector2l operator /(Vector2l a, long b)
		{
			return new Vector2l(a.X / b, a.Y / b);
		}

		public long X { get; private set; }
		public long Y { get; private set; }
		public double SqrLength { get; private set; }
		public double SqrtLength { get; private set; }
	}
}
